package de.hdodenhof.circleimageview.sample.ui.fragment.butterknife;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.sample.R;

public class ButterKnifeAdapter extends BaseAdapter {

    Context mContext;
    LayoutInflater mInflate;
    public ButterKnifeAdapter(Context context){
        this.mContext = context;
        mInflate = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder;
        if (view != null) {
            holder = (ViewHolder) view.getTag();
        } else {
            view = mInflate.inflate(R.layout.butterknife_list_item, parent, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }
        holder.name.setText("姓名："+ position);
        holder.job.setText("工作: " + position);
        return view;
    }

    static class ViewHolder {
        @BindView(R.id.tv_name)
        TextView name;
        @BindView(R.id.tv_job)
        TextView job;

        public ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
